package com.df.tank.strategy;

import com.df.tank.Bullet;
import com.df.tank.Tank;

public class DoubleFireStrategy implements FireStrategy {
    private static final DoubleFireStrategy instance = new DoubleFireStrategy();
    private DoubleFireStrategy(){}

    public static DoubleFireStrategy getInstance() {
        return instance;
    }

    @Override
    public void reload(Tank tank) {
        int bx = tank.getX() + Tank.WIDTH / 2 - Bullet.WIDTH / 2;
        int by = tank.getY() + Tank.HEIGHT / 2 - Bullet.HEIGHT / 2;
        new Bullet(bx, by, tank.getDir(), tank.getGroup(), tank.getTankFrame());
        switch (tank.getDir()) {
            case LEFT:
            case RIGHT:
                bx += Bullet.WIDTH;
                break;
            case UP:
            case DOWN:
                by += Bullet.HEIGHT;
        }
        new Bullet(bx , by, tank.getDir(), tank.getGroup(), tank.getTankFrame());
    }
}
